<template>
  <div id="app">
    <el-container class="main-container">
      <el-header class="header">
        <div class="header-content">
          <h1 class="title">自动化性能平台</h1>
        </div>
      </el-header>
      <el-container>
        <el-aside width="200px" class="sidebar">
          <el-menu :default-active="activeMenu" @select="handleMenuSelect" class="menu" background-color="#545c64"
            text-color="#fff" active-text-color="#409EFF" unique-opened>
            <el-menu-item index="har" class="menu-item">
              <i class="el-icon-document"></i>
              <span>录制管理</span>
            </el-menu-item>
            <el-menu-item index="jmx" class="menu-item">
              <i class="el-icon-setting"></i>
              <span>脚本管理</span>
            </el-menu-item>
            <el-menu-item index="execution" class="menu-item">
              <i class="el-icon-time"></i>
              <span>执行管理</span>
            </el-menu-item>
            <el-menu-item index="machine" class="menu-item">
              <i class="el-icon-monitor"></i>
              <span>远程机管理</span>
            </el-menu-item>
          </el-menu>
        </el-aside>
        <el-main class="main-content">
          <router-view></router-view>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script>
export default {
  data() {
    return {
      activeMenu: "har"
    };
  },
  watch: {
    $route(to) {
      this.activeMenu = to.path.split('/').pop();
    }
  },
  methods: {
    handleMenuSelect(key) {
      this.activeMenu = key;
      this.$router.push({ path: `/${key}` });
    }
  }
}
</script>

<style scoped>
.main-container {
  height: 100vh;
  min-height: 100vh;
}

.header {
  background-color: #409EFF;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  padding: 0;
  z-index: 100;
}

.header-content {
  display: flex;
  align-items: center;
  height: 100%;
  padding-left: 20px;
}

.title {
  color: white;
  margin: 0;
  font-size: 24px;
  font-weight: 600;
}

.sidebar {
  background-color: #545c64;
  box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
  height: calc(100vh - 60px);
}

.menu {
  border-right: none;
  height: 100%;
}

.menu-item {
  font-size: 16px;
}

.menu-item:hover {
  background-color: #434b55 !important;
}

.menu-item.is-active {
  background-color: #434b55 !important;
}

.main-content {
  background-color: #f5f7fa;
  padding: 20px;
  height: calc(100vh - 60px);
}
</style>